package com.kbt.service;

import com.kbt.model.data.GoodForOrderInfoModel;
import com.kbt.model.data.OrderInfoModel;
import com.kbt.util.data.StaticData;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * @author zhgk
 * @package: com.kbt.service
 * @TODO: 提供订单的查询服务
 * @data: 2015/8/19 17:05
 * @version: V1.0
 */
public class OrderQueryService {

    String status[] = {"待付款", "待发货", "待收货", "待评价", "已完成", "退款中", "已退款", "已补发", "已取消"};
    String reason[] = {"申请补货", "申请换货", "申请退款"};
    String sh_status[] = {"买家申请", "卖家批准", "买家回寄商品", "卖家签收", "卖家退款", "买家确认"};
    String all[] = {"待付款", "待发货", "待收货", "待评价",  "已取消","申请补货", "申请换货", "申请退款"};

    public List<OrderInfoModel> queryAllOrderByUserId(String userId) {


        List<OrderInfoModel> orderList = new ArrayList<OrderInfoModel>();


        for (int i = 0; i < 5; i++) {
            OrderInfoModel orderInfoModel = new OrderInfoModel();
            orderInfoModel.setOrderNo("2015081917203200");
            orderInfoModel.setOrderCreateTime("2015-08-20 00:00:00");
            orderInfoModel.setOrderGoodCount(new Random().nextInt(5) + 1);
            orderInfoModel.setOrderTotalFee(1200.00f);
//            if (orderInfoModel.getOrderStatus().equals("订单微信"))
            orderInfoModel.setOrderStatus(all[new Random().nextInt(7)]);//订单状态
            orderInfoModel.setOrderShStatus(sh_status[new Random().nextInt(5)]);//售后状态
            orderInfoModel.setOrderShReason("售后原因");
            List<GoodForOrderInfoModel> goodList = new ArrayList<GoodForOrderInfoModel>();
            GoodForOrderInfoModel goodInfo;
            for (int j = 0; j < orderInfoModel.getOrderGoodCount(); j++) {
                goodInfo = new GoodForOrderInfoModel();
                goodInfo.setOrderNo(orderInfoModel.getOrderNo());
                goodInfo.setGoodCount(new Random().nextInt(5) + 1);
                goodInfo.setGoodTitle("商品蛋楼盖" + i);
                goodList.add(goodInfo);
            }
            orderInfoModel.setGoodList(goodList);
            orderList.add(orderInfoModel);
        }


        return orderList;
    }

    public List<OrderInfoModel> queryOrderByType(String s, int orderType) {
        List<OrderInfoModel> orderList = new ArrayList<OrderInfoModel>();
        switch (orderType) {
            case StaticData.ALL_ORDER:
                orderList = queryAllOrderByUserId("");
                break;
            case StaticData.WAIT_PAY_ORDER:
                orderList = queryWaitPayOrderByUserId("");
                break;
            case StaticData.WAIT_SEND_ORDER:
                orderList = queryWaitSendOrderByUserId("");
                break;
            case StaticData.WAIT_RECIVE_ORDER:
                orderList = queryWaitReciveByUserId("");
                break;
            case StaticData.FINISH_ORDER:
                orderList = queryFinishPayOrderByUserId("");
                break;
            case StaticData.RETURN_ORDER:
                orderList = queryWaitReturnOrderByUserId("");
                break;

        }


        return orderList;
    }

    public List<OrderInfoModel> queryWaitPayOrderByUserId(String userId) {


        List<OrderInfoModel> orderList = new ArrayList<OrderInfoModel>();

        for (int i = 0; i < 5; i++) {
            OrderInfoModel orderInfoModel = new OrderInfoModel();
            orderInfoModel.setOrderNo("2015081917203200");
            orderInfoModel.setOrderCreateTime("2015-08-20 00:00:00");
            orderInfoModel.setOrderGoodCount(new Random().nextInt(5) + 1);
            orderInfoModel.setOrderTotalFee(1200.00f);
            orderInfoModel.setOrderStatus("待付款");
            List<GoodForOrderInfoModel> goodList = new ArrayList<GoodForOrderInfoModel>();
            GoodForOrderInfoModel goodInfo;
            for (int j = 0; j < orderInfoModel.getOrderGoodCount(); j++) {
                goodInfo = new GoodForOrderInfoModel();
                goodInfo.setOrderNo(orderInfoModel.getOrderNo());
                goodInfo.setGoodCount(new Random().nextInt(5) + 1);
                goodInfo.setGoodTitle("商品蛋楼盖" + i);
                goodList.add(goodInfo);
            }
            orderInfoModel.setGoodList(goodList);
            orderList.add(orderInfoModel);
        }


        return orderList;
    }

    public List<OrderInfoModel> queryWaitSendOrderByUserId(String userId) {


        List<OrderInfoModel> orderList = new ArrayList<OrderInfoModel>();

        for (int i = 0; i < 5; i++) {
            OrderInfoModel orderInfoModel = new OrderInfoModel();
            orderInfoModel.setOrderNo("2015081917203200");
            orderInfoModel.setOrderCreateTime("2015-08-20 00:00:00");
            orderInfoModel.setOrderGoodCount(new Random().nextInt(5) + 1);
            orderInfoModel.setOrderTotalFee(1200.00f);
            orderInfoModel.setOrderStatus("待发货");
            List<GoodForOrderInfoModel> goodList = new ArrayList<GoodForOrderInfoModel>();
            GoodForOrderInfoModel goodInfo;
            for (int j = 0; j < orderInfoModel.getOrderGoodCount(); j++) {
                goodInfo = new GoodForOrderInfoModel();
                goodInfo.setOrderNo(orderInfoModel.getOrderNo());
                goodInfo.setGoodCount(new Random().nextInt(5) + 1);
                goodInfo.setGoodTitle("商品蛋楼盖" + i);
                goodList.add(goodInfo);
            }
            orderInfoModel.setGoodList(goodList);
            orderList.add(orderInfoModel);
        }


        return orderList;
    }

    public List<OrderInfoModel> queryWaitReciveByUserId(String userId) {


        List<OrderInfoModel> orderList = new ArrayList<OrderInfoModel>();

        for (int i = 0; i < 5; i++) {
            OrderInfoModel orderInfoModel = new OrderInfoModel();
            orderInfoModel.setOrderNo("2015081917203200");
            orderInfoModel.setOrderCreateTime("2015-08-20 00:00:00");
            orderInfoModel.setOrderGoodCount(new Random().nextInt(5) + 1);
            orderInfoModel.setOrderTotalFee(1200.00f);
            orderInfoModel.setOrderStatus("待收货");
            List<GoodForOrderInfoModel> goodList = new ArrayList<GoodForOrderInfoModel>();
            GoodForOrderInfoModel goodInfo;
            for (int j = 0; j < orderInfoModel.getOrderGoodCount(); j++) {
                goodInfo = new GoodForOrderInfoModel();
                goodInfo.setOrderNo(orderInfoModel.getOrderNo());
                goodInfo.setGoodCount(new Random().nextInt(5) + 1);
                goodInfo.setGoodTitle("商品蛋楼盖" + i);
                goodList.add(goodInfo);
            }
            orderInfoModel.setGoodList(goodList);
            orderList.add(orderInfoModel);
        }


        return orderList;
    }

    public List<OrderInfoModel> queryFinishPayOrderByUserId(String userId) {


        List<OrderInfoModel> orderList = new ArrayList<OrderInfoModel>();

        for (int i = 0; i < 5; i++) {
            OrderInfoModel orderInfoModel = new OrderInfoModel();
            orderInfoModel.setOrderNo("2015081917203200");
            orderInfoModel.setOrderCreateTime("2015-08-20 00:00:00");
            orderInfoModel.setOrderGoodCount(new Random().nextInt(5) + 1);
            orderInfoModel.setOrderTotalFee(1200.00f);
            orderInfoModel.setOrderStatus("待评价");
            List<GoodForOrderInfoModel> goodList = new ArrayList<GoodForOrderInfoModel>();
            GoodForOrderInfoModel goodInfo;
            for (int j = 0; j < orderInfoModel.getOrderGoodCount(); j++) {
                goodInfo = new GoodForOrderInfoModel();
                goodInfo.setOrderNo(orderInfoModel.getOrderNo());
                goodInfo.setGoodCount(new Random().nextInt(5) + 1);
                goodInfo.setGoodTitle("商品蛋楼盖" + i);
                goodList.add(goodInfo);
            }
            orderInfoModel.setGoodList(goodList);
            orderList.add(orderInfoModel);
        }


        return orderList;
    }

    public List<OrderInfoModel> queryWaitReturnOrderByUserId(String userId) {


        List<OrderInfoModel> orderList = new ArrayList<OrderInfoModel>();

        for (int i = 0; i < 5; i++) {
            OrderInfoModel orderInfoModel = new OrderInfoModel();
            orderInfoModel.setOrderNo("2015081917203200");
            orderInfoModel.setOrderCreateTime("2015-08-20 00:00:00");
            orderInfoModel.setOrderGoodCount(new Random().nextInt(3) + 1);
            orderInfoModel.setOrderTotalFee(1200.00f);
            orderInfoModel.setOrderStatus(reason[new Random().nextInt(1) + 1]);
            orderInfoModel.setOrderShReason("少发了货物");
            orderInfoModel.setOrderShStatus(sh_status[new Random().nextInt(5)]);
            List<GoodForOrderInfoModel> goodList = new ArrayList<GoodForOrderInfoModel>();

            GoodForOrderInfoModel goodInfo;
            for (int j = 0; j < orderInfoModel.getOrderGoodCount(); j++) {
                goodInfo = new GoodForOrderInfoModel();
                goodInfo.setOrderNo(orderInfoModel.getOrderNo());
                goodInfo.setGoodCount(new Random().nextInt(5) + 1);
                goodInfo.setGoodTitle("商品蛋楼盖" + i);
                goodList.add(goodInfo);
            }
            orderInfoModel.setGoodList(goodList);
            orderList.add(orderInfoModel);
        }


        return orderList;
    }
}
